<?php

namespace App\Admin\Extensions\Column;

use Encore\Admin\Admin;
use Encore\Admin\Grid\Displayers\AbstractDisplayer;

class Popover extends AbstractDisplayer
{
    public function display($placement = 'left')
    {
        Admin::script("$('[data-toggle=\"popover\"]').popover()");
        Admin::script("$('.popover-dismiss').popover({
                              trigger: 'focus'
                            })");

        $showText = mb_substr($this->value,0,10).'...';
        return <<<EOT
            {$showText}
<a 
tabindex="0" 
    class="btn btn-secondary"
    title="信息"
    data-container="body"
    data-toggle="popover"
    data-placement="$placement"
    data-content="{$this->value}"
    data-trigger="focus"
    <small>查看更多</small>
</a>

EOT;

    }
}
